const express = require('express');
const resultServ = require('../../services/resultService');
const {
    asyncHandler
} = require('../getSendResult')

const router = express.Router();

router.get('/', asyncHandler(async (req, res) => {
    const page = req.query.page || 1;
    const limit = req.query.limit || 10;
    const userId = req.query.userId;
    return await resultServ.getResults(page,limit,userId);

}))

router.get('/:id', asyncHandler(async (req, res) => {
    
    return await resultServ.getResultById(req.params.id);

}))

// 添加一条结果
router.post('/', asyncHandler(async (req, res, next) => {
    return await resultServ.addResult(req.body);
}))



module.exports = router;

